package com.nbsaas.boot.app.rest.resource;

import com.nbsaas.boot.app.api.apis.AppRoleApi;
import com.nbsaas.boot.app.api.domain.request.AppRoleRequest;
import com.nbsaas.boot.app.api.domain.response.AppRoleResponse;
import com.nbsaas.boot.app.api.domain.simple.AppRoleSimple;
import com.nbsaas.boot.app.data.entity.AppRole;
import com.nbsaas.boot.app.data.repository.AppRoleRepository;
import com.nbsaas.boot.app.rest.convert.AppRoleEntityConvert;
import com.nbsaas.boot.app.rest.convert.AppRoleResponseConvert;
import com.nbsaas.boot.app.rest.convert.AppRoleSimpleConvert;
import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.function.Function;

/**
 *   角色-业务接口实现
 */
@Transactional
@Service
public class AppRoleResource extends BaseResource<AppRole, AppRoleResponse, AppRoleSimple, AppRoleRequest> implements AppRoleApi {

    @Resource
    private AppRoleRepository appRoleRepository;

    @Override
    public JpaRepositoryImplementation<AppRole, Serializable> getJpaRepository() {
        return appRoleRepository;
    }

    @Override
    public Function<AppRole, AppRoleSimple> getConvertSimple() {
        return new AppRoleSimpleConvert();
    }

    @Override
    public Function<AppRoleRequest, AppRole> getConvertForm() {
        return new AppRoleEntityConvert();
    }

    @Override
    public Function<AppRole, AppRoleResponse> getConvertResponse() {
        return new AppRoleResponseConvert();
    }


}


